package dao.impl;

import dao.BaseDao02;
import dao.UserDao02;
import pojo.User;

public class UserDaoImpl02 extends BaseDao02 implements UserDao02 {
    @Override
    public User queryForUsername(String username) {
        String sql = "select `id`,`username`,`password`,`email` from t_user where `username` = ?;";
        return queryForOne(sql,User.class,username);
    }

    @Override
    public User queryForUsernameAndPassword(String username, String password) {
        String sql = "select `id`,`username`,`password`,`email` from t_user where `username` = ? and password = ?;";
        return queryForOne(sql,User.class,username,password);
    }

    @Override
    public int saveUser(User user) {
        String sql = "insert into t_user(username,password,email) values(?,?,?);";
        return update(sql,user.getUsername(),user.getPassword(),user.getEmail());
    }


}
